//
//  AppDelegate+ShareSDK.m
//  Julong
//
//  Created by 帝云科技 on 2017/8/23.
//  Copyright © 2017年 diyunkeji. All rights reserved.
//

#import "AppDelegate+ShareSDK.h"
#import <ShareSDK/ShareSDK.h>
#import <ShareSDKConnector/ShareSDKConnector.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import "WXApi.h"


#pragma mark - 微信

static NSString *const weixinAppKey = @"wxcf2ba15df3e8820d";
static NSString *const weixinAppSecret = @"38fc424c5b909ba0e4acd6a1d5d5ab9b";

#pragma mark - QQ

static NSString *const QQAppID = @"1106973054";
static NSString *const QQAppKey = @"IdNsqLiwQlmQgcL6";

@implementation AppDelegate (ShareSDK)

- (void)ShareSDKRegist {
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSArray *platforms = @[
                               @(SSDKPlatformTypeQQ),
                               @(SSDKPlatformTypeWechat)
                               ];
        [ShareSDK registerActivePlatforms:platforms
                                 onImport:^(SSDKPlatformType platformType) {
                                     switch (platformType) {
                                         case SSDKPlatformTypeQQ:
                                             [ShareSDKConnector connectQQ:[QQApiInterface class]
                                                        tencentOAuthClass:[TencentOAuth class]];
                                             break;
                                         case SSDKPlatformTypeWechat:
                                             [ShareSDKConnector connectWeChat:[WXApi class]];
                                             break;
                                         default:
                                             break;
                                     }
                                 }
                          onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo) {
                              switch (platformType) {
                                  case SSDKPlatformTypeQQ:
                                      [appInfo SSDKSetupQQByAppId:QQAppID
                                                           appKey:QQAppKey
                                                         authType:SSDKAuthTypeBoth];
                                      break;
                                  case SSDKPlatformTypeWechat:
                                      [appInfo SSDKSetupWeChatByAppId:weixinAppKey
                                                            appSecret:weixinAppSecret];
                                      break;
                                  default:
                                      break;
                              }
                          }];
    });
}

@end
